---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.5.log
  log type:  text
 opened on:  12 May 2025, 17:59:46

. 
. use "C:\Users\sbstjp\OneDrive - Cardiff University\UKPVS.dta" // Prosser, Magasin, Proulx and Haddock, UK Pro
> gressive Values Dataset, September 2024 // Accessed on March 20 2025

. 
. // Create a weight
. 
. gen weight = 1

. 
. * Code age into categories - the other variables are already in such categories
. recode ageNew (min/24=1 "0-24") (25/34=2 "25-34") (35/44=3 "35-44") (45/54=4 "45-54") (55/max=5 "55+"), gener
> ate(age_group)
(616 differences between ageNew and age_group)

. 
. * Generate totals for the weights - these are based on BESW29 as this dataset has political selfid, unlike ce
> nsus data
. replace gender=. if inrange(gender, 3, 5)
(11 real changes made, 11 to missing)

. rename gender FemaleGender

. gen sextot=.
(617 missing values generated)

. replace sextot = 0.50 if FemaleGender == 1 // Male
(241 real changes made)

. replace sextot = 0.50 if FemaleGender == 2 // Female
(365 real changes made)

. 
. gen agetot=.
(617 missing values generated)

. replace agetot = 0.13 if age_group == 1 //18-24
(134 real changes made)

. replace agetot = 0.14 if age_group == 2 //25-34
(193 real changes made)

. replace agetot = 0.19 if age_group == 3 //35-44
(139 real changes made)

. replace agetot = 0.19 if age_group == 4 //45-54
(92 real changes made)

. replace agetot = 0.35 if age_group == 5 //55+
(58 real changes made)

. 
. gen ethtot=.
(617 missing values generated)

. replace ethtot = 0.86 if Ethnicity2 == 1 // White
(200 real changes made)

. replace ethtot = 0.06 if Ethnicity2 == 2 // Asian
(148 real changes made)

. replace ethtot = 0.04 if Ethnicity2 == 3 // Black
(131 real changes made)

. replace ethtot = 0.04 if Ethnicity2 == 4 // Mixed
(117 real changes made)

. 
. gen edcats=.
(617 missing values generated)

. replace edcats=1 if inrange(Education, 1, 15) // Unidiplomaandbelow
(212 real changes made)

. replace edcats=2 if Education==16 // Undergraddegree
(241 real changes made)

. replace edcats=3 if inrange(Education, 17, 18) // Postgradandabove
(164 real changes made)

. 
. gen edtot=.
(617 missing values generated)

. replace edtot = 0.4740 if edcats == 1 // Unidiplomaandbelow
(212 real changes made)

. replace edtot = 0.2969 if edcats == 2 // Undergraddegree
(241 real changes made)

. replace edtot = 0.2291 if edcats == 3 // Postgradandabove
(164 real changes made)

. 
. gen inccats=.
(617 missing values generated)

. replace inccats=1 if inrange(Household_Income, 1, 6) //under 30k
(155 real changes made)

. replace inccats=2 if inrange(Household_Income, 7, 11) //30-60k
(168 real changes made)

. replace inccats=3 if inlist(Household_Income, 12, 13) //60-100k
(173 real changes made)

. replace inccats=4 if inlist(Household_Income, 14, 15) //over 100k
(106 real changes made)

. 
. gen inctot=.
(617 missing values generated)

. replace inctot = 0.3806 if inccats == 1 //under 30k
(155 real changes made)

. replace inctot = 0.3524 if inccats == 2 //30-60k
(168 real changes made)

. replace inctot = 0.1922 if inccats == 3 //60-100k
(173 real changes made)

. replace inctot = 0.0747 if inccats == 4 //over 100k
(106 real changes made)

. 
. * Rake the weights using the Stata survwgt package
. survwgt rake weight , by(FemaleGender age_group Ethnicity2 edcats inccats) totvars(sextot agetot ethtot edtot
>  inctot) generate(rakedweight)

. 
. // Demographics
. 
. *Delete missing values and recode
. replace Household_Income=. if Household_Income==999
(15 real changes made, 15 to missing)

. 
. gen ReligiousAtt=.
(617 missing values generated)

. replace ReligiousAtt=1 if ReligiousAttendance==7
(77 real changes made)

. replace ReligiousAtt=0 if inlist(ReligiousAttendance, 1, 2, 3, 4, 5, 6, 9)
(525 real changes made)

. 
. egen age_centered = mean(ageNew) 

. replace age_centered = ageNew - age_centered
(617 real changes made, 1 to missing)

. gen age_centered_squared = age_centered^2
(1 missing value generated)

. 
. *Create dummies
. gen Graduate=. 
(617 missing values generated)

. replace Graduate=0 if inrange(Education, 1, 15)
(212 real changes made)

. replace Graduate=1 if inrange(Education, 16, 18)
(405 real changes made)

. 
. gen Married=.
(617 missing values generated)

. replace Married=1 if inlist(MaritalStatus, 1, 2)
(207 real changes made)

. replace Married=0 if inrange(MaritalStatus, 3, 8)
(410 real changes made)

. 
. gen Unemployed=. 
(617 missing values generated)

. replace Unemployed=0 if inrange(employment, 1, 3)
(445 real changes made)

. replace Unemployed=1 if employment==4
(46 real changes made)

. 
. // Life Satisfaction
. *Reverse so satisfaction is coded high
. foreach var in LifeSatisfaction {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }

. 
. *Standardize from 1-2, so it's like other dependent variables in the book
. foreach var in rLifeSatisfaction {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rLifeSatis~n |        617    2.805511    .9591166          1          5

. 
. rename srLifeSatisfaction LifeSat

. 
. // Standardize variables 
. egen Age = std(ageNew)
(1 missing value generated)

. egen Income = std(Household_Income)
(15 missing values generated)

. rename PVS pvs1

. egen PVS = std(pvs1)

. 
. // Regressions
. regress LifeSat PVS [pweight=rakedweight], robust 
(sum of wgt is .9999000132083892)

Linear regression                               Number of obs     =        570
                                                F(1, 568)         =       0.06
                                                Prob > F          =     0.8002
                                                R-squared         =     0.0005
                                                Root MSE          =       .244

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         PVS |  -.0054146   .0213831    -0.25   0.800    -.0474141    .0365849
       _cons |   1.450812   .0191718    75.67   0.000     1.413156    1.488468
------------------------------------------------------------------------------

. eststo
(est1 stored)

. regress LifeSat PVS Age FemaleGender Graduate Income Married ReligiousAtt [pweight=rakedweight], robust // on
> e without unemployment, as it reduces the obs 
(sum of wgt is .9808352744254275)

Linear regression                               Number of obs     =        556
                                                F(7, 548)         =       3.90
                                                Prob > F          =     0.0004
                                                R-squared         =     0.1255
                                                Root MSE          =     .23099

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         PVS |   .0000149   .0203251     0.00   0.999    -.0399098    .0399395
         Age |     -.0006   .0188105    -0.03   0.975    -.0375496    .0363496
FemaleGender |  -.0261778   .0374008    -0.70   0.484    -.0996443    .0472887
    Graduate |   .0376619   .0390265     0.97   0.335     -.038998    .1143218
      Income |   .0446764   .0191098     2.34   0.020      .007139    .0822137
     Married |   .1061893   .0401638     2.64   0.008     .0272955    .1850831
ReligiousAtt |  -.0713741   .0806723    -0.88   0.377     -.229839    .0870908
       _cons |   1.453786   .0630013    23.08   0.000     1.330032     1.57754
------------------------------------------------------------------------------

. eststo
(est2 stored)

. regress LifeSat PVS Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight=rakedweight], r
> obust 
(sum of wgt is .6677947957840629)

Linear regression                               Number of obs     =        446
                                                F(8, 437)         =       3.56
                                                Prob > F          =     0.0005
                                                R-squared         =     0.1779
                                                Root MSE          =     .20811

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         PVS |  -.0157366   .0165495    -0.95   0.342     -.048263    .0167899
         Age |  -.0144488   .0221678    -0.65   0.515    -.0580176      .02912
FemaleGender |   -.037197   .0341769    -1.09   0.277    -.1043686    .0299746
    Graduate |    .082443   .0353807     2.33   0.020     .0129056    .1519804
      Income |   .0200123   .0177164     1.13   0.259    -.0148077    .0548323
     Married |   .0809333   .0390848     2.07   0.039     .0041157    .1577508
ReligiousAtt |  -.1031079   .0637679    -1.62   0.107    -.2284377    .0222219
  Unemployed |  -.1440141   .0631908    -2.28   0.023    -.2682098   -.0198185
       _cons |   1.459109   .0584785    24.95   0.000     1.344175    1.574043
------------------------------------------------------------------------------

. eststo
(est3 stored)

. esttab

------------------------------------------------------------
                      (1)             (2)             (3)   
                  LifeSat         LifeSat         LifeSat   
------------------------------------------------------------
PVS              -0.00541       0.0000149         -0.0157   
                  (-0.25)          (0.00)         (-0.95)   

Age                             -0.000600         -0.0144   
                                  (-0.03)         (-0.65)   

FemaleGender                      -0.0262         -0.0372   
                                  (-0.70)         (-1.09)   

Graduate                           0.0377          0.0824*  
                                   (0.97)          (2.33)   

Income                             0.0447*         0.0200   
                                   (2.34)          (1.13)   

Married                             0.106**        0.0809*  
                                   (2.64)          (2.07)   

ReligiousAtt                      -0.0714          -0.103   
                                  (-0.88)         (-1.62)   

Unemployed                                         -0.144*  
                                                  (-2.28)   

_cons               1.451***        1.454***        1.459***
                  (75.67)         (23.08)         (24.95)   
------------------------------------------------------------
N                     570             556             446   
------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.5.log
  log type:  text
 closed on:  12 May 2025, 17:59:57
---------------------------------------------------------------------------------------------------------------
